import { c } from "../../tool/core";
import { cryptPwd } from "../../tool/toll";
let fs = require("fs");
import { movie_insert } from "../../db/insert";
const _ = require("lodash")

export async function movie(item) {

  
  
    // table = table.map(el => {
    //     return _.snakeCase(el)
    // })

    

    Promise.all(item.map(res => {
        let table = ['title','title_id', 'video_id', 'dsc', 'season', 'category', 'url', 'summary']
        let value = [];
         value.push(`'${res.title}'`);
         value.push(`'${cryptPwd(res.title,res.category)}'`)
         value.push(`'${res.video_id || null}'`);
         value.push(`'${res.sub_title || null}'`);
         value.push("'null'");
         value.push(`'${res.category || null}'`);
         value.push(`'${res.video_link || null}'`);
         value.push(`'${res.summary || null}'`);
        // console.log(res)
        // console.log(value)
    movie_insert(res.category, table, value, res.video_id);

    })
    );

    // console.log(table)

    // fs.writeFileSync("./九州缥缈录.html", res.body, "utf-8");

    // console.log("");
}
// 字段替换步骤